﻿<!DOCTYPE html>
<html lang="en">

<head>
    <title>切换视频</title>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <style>
        #example {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
        }
    </style>

</head>

<body>
    <div id="example"></div>
    <div style="position:absolute;bottom:0px;background:rgb(114, 109, 109);z-index: 999;">
        <button id="switch">切换视频</button>
    </div>

    <script src="../build/three.js"></script>
    <script src="../build/mxreality.js"></script>
    <script src="../build/hls.js"></script>
    <script>


        window.onload = function () {
            init();
        }
        //var vr=new VR(scene,renderer,container);
        function init() {
            
            //renderer = new THREE.WebGLRenderer();
            if (navigator.userAgent.match(/iphone os 14_0/i) || navigator.userAgent.match(/iphone os 14_1/i) ||
                navigator.userAgent.match(/iphone os 14_3/i)) {
                AVR.__fixHlsRender = true;
            }
            var vr = new VR({ 'id': 'example', 'camera_para': { "fov": 50 } });

            //vr.playText="<img src='img/play90.png' width='40' height='40'/>";
            vr.vrbox.radius = 600;
            if (AVR.isCrossScreen()) {
                // 调整vr视窗偏移量
                vr.effect.separation = 1.2;
            }
            vr.loadProgressManager.onLoad = function () {
                // 视频静音

            }
            //AVR.useGyroscope=false;
            vr.init(function () {

            });

            var options = { 'muted': true, 'autoplay': true };
            vr.play('http://ivi.bupt.edu.cn/hls/cctv5phd.m3u8', vr.resType.sliceVideo, options);
            vr.video.setAttribute("loop", "loop");
            vr.video.crossOrigin = "Anonymous";

            document.getElementById('switch').addEventListener('click', function (e) {
                vr.play('http://playertest.longtailvideo.com/adaptive/bipbop/gear4/prog_index.m3u8',
                    vr.resType.sliceVideo, options)
            }, false);

            vr.video.onended = function () {
            }

        }


    </script>
</body>

</html>